#include "itemwithlabel.h"
#include "ui_itemwithlabel.h"
#include "common/common.h"

ItemWithLabel::ItemWithLabel(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ItemWithLabel)
{
    ui->setupUi(this);
    ui->label_v->adjustSize();
    ui->label_v->setWordWrap(true);
    //ui->label_v->setAlignment(Qt::AlignTop);
    ui->label_v->installEventFilter(this);
}

ItemWithLabel::~ItemWithLabel()
{
    delete ui;
}

void ItemWithLabel::setShowName(const QString &str)
{
    ui->label->setText(str);
}

void ItemWithLabel::setShowValue(const QString &str)
{
    ui->label_v->setText(str);
}

bool ItemWithLabel::eventFilter(QObject *ob, QEvent *e)
{
    if(ob==ui->label_v)
    {
        if(e->type()==QEvent::MouseButtonPress)
        {
            emit clicked();
            return true;
        }
    }
    return QWidget::eventFilter(ob,e);

}
